<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="keywords" content="pinpin社保" />
	<meta name="description" content="pinpin社保" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>社保运营后台-手动减员</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
</head>
<body>
	<div id="wrapper">
        <%@ include file="/WEB-INF/jsp/common/menu.jsp" %>
        <div id="page-wrapper">
        	<div class="row">
                <div class="col-lg-12">
                    <!-- 路径导航 -->
                    <ol class="breadcrumb">
				      <li>社保后台</li>
				      <li class="active">手动减员列表</li>
				    </ol>
                </div>
            </div>
            <div class="row">
            	<div class="col-lg-12">
            		<div class="panel panel-default">
            			<div class="panel-body">
        			    	<div class="form-inline dt-bootstrap no-footer">
        			    		<!-- 表单查询 -->
        			    		<div class="row">
        			    			<div class="col-lg-12">
        			    			<form action="${list_uri }" method="POST" class="form-check" id="queryOrderForm">
        			    				<label class="checkbox-inline">
	                                        <c:set var="citySelectPCitys" value="${pCitySet }" scope="request"/>
	                                        <c:set var="citySelectCitys" value="${existedCityList }" scope="request"/>
	                                        <jsp:include page="/WEB-INF/jsp/common/citySelect.jsp">
	                                        	<jsp:param name="id" value="city_code" />
	                                        	<jsp:param name="name" value="city_code" />
	                                        	<jsp:param name="value" value="${form.city_code }" />
	                                        </jsp:include> 
                                        </label>
        			    			    <label class="checkbox-inline" style="margin-top:10px">
                                        	<select name="status" class="form-control">
                                        		<option value="0">所有申请状态</option>
                                        		<option value="2" <c:if test="${form.status==2 }">selected</c:if>>新申请</option>
                                        		<option value="3" <c:if test="${form.status==3 }">selected</c:if>>申请减员中</option>
                                        		<option value="4" <c:if test="${form.status==4 }">selected</c:if>>已成功减员</option>
                                        	</select>
        			    			    </label>
        			    				<label class="checkbox-inline" style="margin-top:10px">
                                        <input type="text" class="form-control" name="phone" placeholder="请输入一个手机号" value="${form.phone }">
                                        </label>
        			    			    <label class="checkbox-inline" style="margin-top:10px">
                                        	<input type="text" class="form-control" name="userName" id="userName" placeholder="参保人的姓名"  value="${form.userName }">
        			    			    </label>
        			    			    <br>
        			    			    <label class="checkbox-inline" style="margin-top:10px">所属月份： 
                                        	<input type="text" class="form-control" name="opt_month" id="month" placeholder="请选择订单的年月" onClick="WdatePicker({dateFmt:'yyyyMM',minDate:'2015-10-01 00:00:00'})" value="${form.opt_month }" onblur="return checkDate()">
        			    			    </label>
        			    			    <label class="checkbox-inline" style="margin-top:10px">生成时间： 
        			    			    	<input type="text" class="form-control" name="start_time" placeholder="申请时间-开始" onClick="WdatePicker()" value="${form.start_time }">
	                                        ~ &nbsp;
	        			    				<input type="text" class="form-control" name="end_time" placeholder="申请时间区间-结束" onClick="WdatePicker()"  value="${form.end_time }">
        			    			    </label>
        			    			    <br>
        			    				<label class="checkbox-inline" style="margin-top:10px">身份证：
        			    			    	<textarea name="id_card" cols="93" class="form-control" placeholder="多个身份证以 英文逗号(,) 间隔">${form.id_card}</textarea>
        			    			     </label>
        			    			    <input type="hidden" name="pageNo" id="fpageNo" value="${form.pageNo }">
        			    			    <label class="checkbox-inline" style="margin-top:20px">
	        			    			    <button type="submit" class="btn btn-primary">查 询</button>
	        			    			    <button type="button" class="btn btn-primary" onclick="clear_form('queryOrderForm')">重置</button>
        			    			    </label>
        			    			    </form>
        			    			</div>
        			    		</div>
        			    			    <br>
        			    		<!-- 分页 -->
        			    		<div class="row">
        			    			<div class="col-lg-4 form-inline">
        			    				<button type="button" onclick="exportHandDec()" class="btn btn-info" id="dec_exp_btn">批量导出</button>
        			    				<button type="button" onclick="applyingDec()" class="btn btn-primary"  id="dec_apply_btn">正在申请减员</button>
        			    				<button type="button" onclick="decOk()" class="btn btn-warning" id="dec_ok_btn">已成功减员</button>
        			    				<button type="button" onclick="del()" class="btn btn-danger" id="dec_del_btn"> 删 除 </button>
        			    			</div>
        			    			<div class="col-lg-8">
	        			    			<%@ include file="../paging.jsp" %>
           			    			</div>
        			    		</div>
        			    		<hr/>
        			    		<!-- 表格列表 -->
        			    		<div class="row">
        			    			<div class="col-lg-12">
        			    				<table id="dataContent" class="table table-striped table-bordered table-hover no-footer table-title" role="grid">
        			    					<thead>
        			    						<tr><th title="全选"><label><input type="checkbox" name="selectAll" id="selectAll" onclick="javascript:selectAll(this,'pids')">全选</label></th>
                                                    <th>姓名</th>
                                                    <th>身份证</th>
                                                    <th>联系手机号</th>  
                                                    <th>城市</th>  
                                                    <th>类型</th>  
                                                    <th title="可能与订单员不同">减员月份</th>  
                                                    <th>所属月份</th>  
                                                    <th>加急</th>
                                                    <th>申请状态</th>  
                                                    <th>申请人</th>                                         
                                                    <th>生成时间</th>                                         
                                                    <th>最新时间</th> 
                                                </tr>
        			    					</thead>
        			    					<tbody>
        			    					<c:forEach items="${pageModel.recordList }" var="order">
        			    						<tr role="row">
        			    							<td>
        			    							    <input type="checkbox" name="pids" value="${order.order_no }" />
        			    							</td>
                                                    <td>${order.user_name }</td>
                                                    <td>${order.id_card }</td>
                                                    <td>${order.phone }</td>
        			    							<td>${order.city_name }</td>
        			    							<td>${order.pay_for} </td>
        			    							<td>${order.via_month} </td>
                                                    <td>${order.opt_month }</td>
                                                    <td><b>${order.urgent }</b></td>
                                                    <td><span <c:if test="${fn:indexOf(order.status, '成功') > -1 }">class="text-success"</c:if>>${order.status }</span></td>
                                                    <td><a href="javascript:logList('${order.order_no }');" id="a${order.order_no }">${order.opt_user }</a></td>
                                                    <td>${order.gen_time }</td>
                                                    <td>${order.update_time }</td>
                                                </tr>
        			    					</c:forEach>
        			    					</tbody>
        			    				</table>
        			    			</div>

        			    		</div>
        			    		<!-- 分页 -->
                                <br/>
        			    		<div class="row">
        			    			<div class="col-lg-2">
        			    			</div>
        			    			<div class="col-lg-10">
        			    				<%@ include file="../paging.jsp" %>
        			    			</div>
        			    		</div>
        			    	</div>
            			</div>
            		</div>
            	</div>
            </div>
        </div>
	</div>
	<div id="logListBox" style="display:none;width:660px">
		<table class="table table-striped table-bordered table-hover no-footer" role="grid">
			<thead>
				<tr>
					<th>操作人</th>
	                <th>描述</th>
	                <th>时间</th>
	               </tr>
			</thead>
			<tbody id="logListTbody">
				<!-- <tr role="row"> <td>111</td> <td>111</td> <td>111</td></tr> -->
			</tbody>
		</table>
	</div>
</body>
<script type="text/javascript">
var hd_export_uri = "${hd_export_uri}";
var hd_apply_uri = "${hd_apply_uri}";
var hd_ok_uri = "${hd_ok_uri}";
var hd_del_uri = "${hd_del_uri}";
var view_logs_uri = "${view_logs_uri}";

function selectAll(btn,items){
	var selectAll=btn;
	var nid_var=document.getElementsByName(items);
	for(var i = 0; i < nid_var.length; i ++ ) {
		nid_var[i].checked = selectAll.checked;
	}
}
function exportHandDec() {
	iConfirm("dec_exp_btn","确定执行批量导出 ?", "", function(){
		var f = $("#queryOrderForm");
		f.attr("action", hd_export_uri);
		f.submit();
		f.attr("action", "");
		}, 
		function(){});
}
function applyingDec() {
	var orders = $("input[name='pids']:checked").map(function() {
		  return this.value;
	}).get().join(',');
	
	if (orders == "") {
		smokeAlert(500, "请先选择需要【正在申请减员】的数据列");
		return;
	}
	iConfirm("dec_apply_btn", " 确定更改状态 ?", 
			"本操作只修改【新申请】状态的数据。<br> 记录操作日志。", function(){
		$.post(hd_apply_uri, {order_nos: orders}, function(result, textStatus){
	  		 if (result.code == 200) {
	 			notice(result.data, 15);
			} else {
				notice(result.msg, -1);
			}
	  	});
		});	
}
function decOk() {
	var orders = $("input[name='pids']:checked").map(function() {
		  return this.value;
	}).get().join(',');
	
	if (orders == "") {
		smokeAlert(500, "请先选择需要【已成功减员】的数据列");
		return;
	}
	iConfirm("dec_ok_btn", 
			"确定更改 为  已成功减员  ?",
			"本操作只修改处于【申请减员中】的数据。<br> 状态更改成功的数据,系统将发送<b>短信通知用户</b>。<br> 记录操作日志。",  function(){
		$.post(hd_ok_uri, {order_nos: orders}, function(result, textStatus){
	  		 if (result.code == 200) {
	 			notice(result.data, 15);
			} else {
				notice(result.msg, -1);
			}
	  	});
	});
}


function del() {
	var orders = $("input[name='pids']:checked").map(function() {
		  return this.value;
	}).get().join(',');
	
	if (orders == "") {
		smokeAlert(500, "请先选择处于【新申请】状态的数据列");
		return;
	}
	iConfirm("dec_del_btn", "确定 删除  ?",
			"本操作只适用处于【新申请】状态的数据。<br> 本操作记录日志 </b>。", 
			 function(){
		$.post(hd_del_uri, {order_nos: orders}, function(result, textStatus){
	  		 if (result.code == 200) {
	 			notice(result.data, 10);
			} else {
				notice(result.msg, -1);
			}
	  	});
	});
}

function logList(order_no) {
	   var content = document.getElementById("logListBox");
	   dialog({
		   title : '操作日志',
		   content : content,
		   follow : document.getElementById("a"+order_no),
		   quickClose : true
	   }).show();

	   $.get(view_logs_uri+"?order_no="+order_no, function(result, textStatus) {
		   var _tbody = $("#logListTbody");
		   _tbody.html("");
		   if (result.code != 200) {
			   notice(result.msg);
			   return;
		   }
		   $.each(result.data, function(index, data){
			   _tbody.append('<tr role="row"> <td>'+data.opt_user+'</td> <td>'+data.opt_content+'</td> <td>'
					   +new Date(data.gen_time).format("yyyy-MM-dd hh:mm:ss")+'</td></tr>');
		   });
		});
	}
</script>
</html>